<?php
class Tourism_freight_price_list_model extends BZ_Model
{

    protected $table = 'tourism_freight_price_list';

    /*
     *增加记录
     * */
    public function addList($list_params)
    {
        $this->db->insert_batch($this->table, $list_params);
        return $this->db->affected_rows();
    }

    /*
     *删除记录
     * */
    public function deleteList($id)
    {
        $this->db->where('tid', $id);
        return $this->db->delete($this->table);
    }

    public function getFreight($tid, $is_default = 0)
    {
        $this->db->where('tid', $tid);
        $this->db->where('is_default', $is_default);
        return $this->db->get($this->table);
    }

    public function getFreightRow($params)
    {
        $sql = 'tid = ' . $params['id'] . ' and (is_default = 1 or area like "%' . $params['area'] . '%")';
        $this->db->where($sql);
        $this->db->order_by('is_default', 'asc');
        return $this->db->get($this->table)->row();
    }
}